from src.tools.format import cookie_str_to_dict

class Cookie:
    def __init__(self):
        self.cookie = []

    def run(self, cookie):
        self.extract(cookie)

    def extract(self, cookie: str) -> dict:
        cookie_dict = cookie_str_to_dict(cookie)
        self.__check_state(cookie_dict)
        self.cookie = cookie_dict
        return cookie_dict

    def __check_state(self, items: dict) -> None:
        if items.get("sessionid_ss"):
            print("当前 Cookie 已登录")
        else:
            print("当前 Cookie 未登录")